<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JavaScript for...in 语句遍历对象的属性</title>
</head>
<body>
<!--for...in 循环中的代码块会为每个属性执行一次-->
<p id="demo"></p>

<script>
  var txt = "";
  var person = {fname:"Bill",lname:"Gates",age:62};
  var x;
  for (x in person){
    txt += person[x] + " ";
  }
  document.getElementById("demo").innerHTML = txt;
</script>
</body>
</html>